package pers.course.week3;

import java.util.Scanner;

public class FooBarBa {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nums = in.nextInt();
        for (int i = 0; i < nums; i++) {
            int from = in.nextInt();
            int to = in.nextInt();
            if (from > to) {
                if (from%2 == 0) {
                    System.out.println();
                    continue;
                }
            }
            for (int j = from; j <= to; j++) {
                if (j % 3 == 0) {
                    System.out.println(j + " foo");
                }else if (j % 5 == 0) {
                    System.out.println(j + " bar");
                }else if (j % 7 == 0) {
                    System.out.println(j + " baz");
                }else {
                    System.out.println(j);
                }
            }
        }
    }
}
